package demo4;

import java.util.Scanner;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: Administrator
 * Date: 2023-07-07
 * Time: 20:47
 */
class PasswordException extends RuntimeException{
    public PasswordException() {
    }

    public PasswordException(String message) {
        super(message);
    }
}
class  userException extends RuntimeException{
    public userException() {
    }

    public userException(String message) {
        super(message);
    }
}
public class Test {
    public static void main(String[] args) {
        String name = "zhangsan";
        String passworld = "123456";
        Scanner scanner = new Scanner(System.in);
        System.out.println("请输入用户名");
        String username = scanner.nextLine();
        System.out.println("请输入密码");
        String userpassworld = scanner.nextLine();
        if(name.equals(username)){
            if(passworld.equals(userpassworld)){
                System.out.println("登录成功");
            }else{
                throw new PasswordException("密码错误"+passworld);
            }
        }else {
            throw new userException("用户名输入错误");
        }
    }
}
